package lpl.com.xyd.test.manage.common.enums;

import java.util.Arrays;
import java.util.List;

public enum ProjectStatusEnum {
    NEW("NEW","待开发"),
    DOING("DOING","开发中"),
    DONE("DONE","开发完成"),
    TEST("TEST","测试中"),
    TEST_DONE("TEST_DONE","测试完成"),
    ONLINE("ONLINE","上线完成");

    private String code;
    private String message;

    ProjectStatusEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    /**
     *  根据code获取枚举描述
     * @param code
     * @return
     */
    public static String getMsgByCode(String code){
        List<ProjectStatusEnum> _enumList = getAll();
        for (ProjectStatusEnum _enum : _enumList){
            if (_enum.getCode().equals(code)){
                return _enum.getMessage();
            }
        }
        return null;
    }

    /**
     * 根据code获取枚举类
     * @param code
     * @return
     */
    public static ProjectStatusEnum getByCode(String code){
        List<ProjectStatusEnum> errorcedeEnumList = getAll();
        for (ProjectStatusEnum _enum : errorcedeEnumList){
            if (_enum.getCode().equals(code)){
                return _enum;
            }
        }
        return null;
    }

    /**
     * 根据code获取枚举类
     * @param message
     * @return
     */
    public static ProjectStatusEnum getByMessage(String message){
        List<ProjectStatusEnum> errorcedeEnumList = getAll();
        for (ProjectStatusEnum _enum : errorcedeEnumList){
            if (_enum.getMessage().equals(message)){
                return _enum;
            }
        }
        return null;
    }


    public static String getCodeByMessage(String message){
        List<ProjectStatusEnum> errorcedeEnumList = getAll();
        for (ProjectStatusEnum _enum : errorcedeEnumList){
            if (_enum.getMessage().equals(message)){
                return _enum.getCode();
            }
        }
        return null;
    }
    /**
     * 获取所有枚举
     * @return
     */
    public static List<ProjectStatusEnum> getAll(){
        return Arrays.asList(ProjectStatusEnum.values());
    }

}
